//
//  RootViewController.m
//  LazyEnglish
//
//  Created by lanou3g on 16/1/5.
//  Copyright © 2016年 李洋. All rights reserved.
//

#import "RootViewController.h"
#import "UIImage+image.h"
#import "ListenToBookController.h"
#import "HomeViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

-(void)viewDidLoad{
    //添加所有子控件
    [self setUpAllChildController];
    
    
    
}

-(void)setUpAllChildController{
    
    
    HomeViewController *home = [[HomeViewController alloc] init];
    [self setupOneChildViewController:home image:[UIImage imageNamed:@"首页"] selectedImage:[UIImage imageWithRenderingOriginaName:@"首页"] title:@"首页"];
    
    ListenToBookController *listen  =[[ListenToBookController alloc] init];
    [self setupOneChildViewController:listen image:[UIImage imageNamed:@"听书城"] selectedImage:[UIImage imageWithRenderingOriginaName:@"听书城"] title:@"听书城"];
    
    UIViewController *down =[[UIViewController alloc] init];
    [self setupOneChildViewController:down image:[UIImage imageNamed:@"下载听"] selectedImage:[UIImage imageWithRenderingOriginaName:@"下载听"] title:@"下载听"];
    
    UIViewController *fanyi =[[UIViewController alloc] init];
    [self setupOneChildViewController:fanyi image:[UIImage imageNamed:@"翻译"] selectedImage:[UIImage imageWithRenderingOriginaName:@"翻译"] title:@"翻译"];
    
    
}


#pragma mark  添加一个控制器设置
-(void)setupOneChildViewController:(UIViewController *)vc image:(UIImage *)image selectedImage:(UIImage *)selectedImage title:(NSString *)title{
    
    vc.tabBarItem =[[UITabBarItem alloc] initWithTitle:title image:image selectedImage:selectedImage];
    UINavigationController *NC = [[UINavigationController alloc] initWithRootViewController:vc];
    
    //item字体颜色变化
    NSMutableDictionary *att =[NSMutableDictionary dictionary];
    [att setObject:[UIColor orangeColor] forKey:NSForegroundColorAttributeName];
    [vc.tabBarItem setTitleTextAttributes:att forState:UIControlStateSelected];
    
    [self addChildViewController:NC];
    
    
}



@end
